package com.itheima;

import java.util.ArrayList;
import java.util.Collections;
import java.util.stream.Stream;

public class myfunctionDemo01 {
    public static void main(String[] args) {
        //集合中存储一些字符串的数据，比如：张三,23
        //收集到Student类型的数组当中（使用方法引用完成）

        ArrayList<String> list = new ArrayList<>();
        Collections.addAll(list,"张三,23","李四,24","王五,25");

//        List<Student> collect = list.stream().map(new Function<String, Student>() {
//            @Override
//            public Student apply(String s) {
//                String name = s.split(",")[0];
//                int age = Integer.parseInt(s.split(",")[1]);
//                return new Student(name, age);
//            }
//        }).collect(Collectors.toList());

        Stream<Student> studentStream = list.stream().map(Student::new);
        studentStream.forEach(System.out::println);

    }
}
